package com.cy.store.controller;

import com.cy.store.entity.District;
import com.cy.store.service.IDistrictService;
import com.cy.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Luo Sheng
 * @school YiBin university
 * @create 2022-12-06 18:20
 */
@RestController
@RequestMapping("/districts")
public class DistrictController extends BaseController{
    @Autowired
    private IDistrictService districtService;

    @GetMapping({"/",""}) // districts开头的请求都被拦截到getByParent方法
    public JsonResult<List<District>> getByParent(String parent){
        // 调用业务层方法查询地区数据
        List<District> data = districtService.getByParent(parent);
        return new JsonResult<>(OK,data);
    }
}
